package com.yuanfeng.base.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yuanfeng.base.entity.BaseCommonCornerMarkerEntity;
import com.yuanfeng.base.mapper.BaseCommonCornerMarkerMapper;
import com.yuanfeng.base.service.BaseCommonCornerMarkerService;
import com.yuanfeng.commoms.util.ResponseResult;
import com.yuanfeng.commoms.util.querypage.PageUtils;
import com.yuanfeng.commoms.util.querypage.Query;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 *
 */
@Service
public class BaseCommonCornerMarkerServiceImpl extends ServiceImpl<BaseCommonCornerMarkerMapper, BaseCommonCornerMarkerEntity>
    implements BaseCommonCornerMarkerService{

    @Override
    public ResponseResult queryCornerMarkerList(Map<String, Object> param) {



        IPage<BaseCommonCornerMarkerEntity> page=this.page(new Query<BaseCommonCornerMarkerEntity>().getPage(param),
                        new LambdaQueryWrapper<BaseCommonCornerMarkerEntity>().orderByDesc(BaseCommonCornerMarkerEntity::getUpdateDate));

        return ResponseResult.success(PageUtils.getPage(page));
    }

    @Override
    public ResponseResult updateCornerMarker(Map<String, Object> param) {
        if (null == param.get("cornerId")) {
            this.baseMapper.insertCornerMarker(param);
        } else {
            this.baseMapper.updateCornerMarker(param);
            if (Integer.valueOf(param.get("cornerIsEnable").toString()) == 2) {
                this.baseMapper.updateGoodsCornerEnable(param);
            }

        }

        return ResponseResult.success();
    }
}




